/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logiclander.adhocracy.jira.cli;

import com.atlassian.jira.rest.client.domain.Issue;
import com.logiclander.adhocracy.cli.CommandLineReactor;

/**
 *
 * @author tim
 */
public class JiraShowIssueReactor implements CommandLineReactor {

    private boolean initialized = false;
    final Issue issue;

    public JiraShowIssueReactor(Issue i) {
        issue = i;
    }
    
    public void init() {
        initialized = true;
        System.out.println("----------------------------------------------------------------------");
        System.out.println("-- IssueSummary                                                     --");
        System.out.println("----------------------------------------------------------------------");
    }

    public void process() {
        System.out.println("     key: " + issue.getKey());
        System.out.println(" summary: " + issue.getSummary());
        System.out.println("  status: " + issue.getStatus().getName());
        System.out.println("reporter: " + issue.getReporter().getName());
        if (issue.getAssignee() != null) {
            System.out.println("assignee: " + issue.getAssignee().getName());
        }
        if (issue.getField("customfield_10320") != null) {
            System.out.println("    rank: " + issue.getField("customfield_10320").getValue());
        }
        System.out.println("----------------------------------------------------------------------");
    }

    public void destroy() {
        initialized = false;
    }
}
